﻿using System;
using System.Collections.Generic;
using System.Text;
using Barbar.UrlGuard.Dal;
using System.Windows.Forms;

namespace Barbar.UrlGuard.Controls {
  public partial class AuthenticationBasicControl : UserControl, IInjector<AuthenticationBasic> {
    private TextBox txtUserName;
    private TextBox txtPassword;

    public AuthenticationBasicControl() {
      InitializeComponent();
    }

    #region IInjector<AuthenticationBasic> Members

    public void SaveData(AuthenticationBasic instance) {
      if (instance == null)
        throw new ArgumentNullException("instance");

      instance.UserName = txtUserName.Text;
      instance.Password = txtPassword.Text;
    }

    #endregion

    #region IReadOnlyInjector<AuthenticationBasic> Members

    public void LoadData(AuthenticationBasic readOnlyInstance) {
      if (readOnlyInstance == null) {
        txtUserName.Text = string.Empty;
        txtPassword.Text = string.Empty;
      } else {
        txtUserName.Text = readOnlyInstance.UserName;
        txtPassword.Text = readOnlyInstance.Password;
      }
    }

    #endregion

   
  }
}
